/**
 * Created by apple on 2017/11/13.
 */

import React, {Component} from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  ScrollView,
  WebView
} from 'react-native';
import Request from '../../publicServer/request'
import { Tabs } from 'antd-mobile';

const url = 'http://imooc.com';

export default class My extends Component {
  constructor(props){
    super(props);
    this.state={
      url:url,
      title:''
    }
  }
  change(e){
    console.log(e);
    this.setState({
      title:e.title
    })
  }
  go(){
    console.log(this.state.title)
    this.setState({
      url:'http://www.baidu.com'
    })
  }
  render() {
    const style = {
        alignItems: 'center',
        justifyContent: 'center',
        height: 150,
        backgroundColor: '#fff',
      };
    return (
      <View style={{ flex: 1 }}>
        <View style={{marginTop:50}}>
          <Text onPress={this.go.bind(this)}>go</Text>
        </View>
        <WebView
          ref={webView =>this.webView = webView}
          onNavigationStateChange={e=>this.change(e)}
          source = {{uri:this.state.url}}
        />
      </View>
    );
  }
}


const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('My', () => My);
